module tskitlib;

private import win32.basetyps, win32.windef, win32.wtypes, win32.oaidl;

enum EN_DATA_STREAM {
  data1 = 0x00000000,
  data2 = 0x00000001,
  data3 = 0x00000002,
  data4 = 0x00000003,
  data5 = 0x00000004,
  data6 = 0x00000005,
  data7 = 0x00000006,
  data8 = 0x00000007,
  data9 = 0x00000008,
  data10 = 0x00000009,
  data11 = 0x0000000A,
  data12 = 0x0000000B,
  data13 = 0x0000000C,
  data14 = 0x0000000D,
  data15 = 0x0000000E,
  data16 = 0x0000000F,
  data17 = 0x00000010,
  data18 = 0x00000011,
  data19 = 0x00000012,
  data20 = 0x00000013,
  data21 = 0x00000014,
  data22 = 0x00000015,
  data23 = 0x00000016,
  data24 = 0x00000017,
  data25 = 0x00000018,
  data26 = 0x00000019,
  data27 = 0x0000001A,
  data28 = 0x0000001B,
  data29 = 0x0000001C,
  data30 = 0x0000001D,
  data31 = 0x0000001E,
  data32 = 0x0000001F,
  data33 = 0x00000020,
  data34 = 0x00000021,
  data35 = 0x00000022,
  data36 = 0x00000023,
  data37 = 0x00000024,
  data38 = 0x00000025,
  data39 = 0x00000026,
  data40 = 0x00000027,
  data41 = 0x00000028,
  data42 = 0x00000029,
  data43 = 0x0000002A,
  data44 = 0x0000002B,
  data45 = 0x0000002C,
  data46 = 0x0000002D,
  data47 = 0x0000002E,
  data48 = 0x0000002F,
  data49 = 0x00000030,
  data50 = 0x00000031,
  dataDefault = 0x000000FF,
}

enum enDataType {
  dtUnknown = 0x00000001,
  dtBoolean = 0x00000002,
  dtTrueFalse = 0x00000002,
  dtString = 0x00000003,
  dtInteger = 0x00000004,
  dtInt64 = 0x00000005,
  dtFloat = 0x00000006,
  dtDouble = 0x00000007,
  dtPointer = 0x0000000B,
  dtHandle = 0x0000000C,
}

enum enPlatformType {
  ptUnknown = 0xFFFFFFFF,
  ptDesktop = 0x00000000,
  ptServer = 0x00000001,
}

struct TSRuntimeErrorItem {
  wchar* sCompany;
  wchar* sErrorCategory;
  wchar* sErrorLocation;
  wchar* sSourceString;
  wchar* sLongString;
  wchar* sShortString;
  int nParameters;
  int nErrorCode;
  int nErrorID;
}

interface IEasyLanguageObject : IDispatch {
//  static GUID IID = { 0x7ceeb700, 0xd59e, 0x11d3, 0x83, 0x94, 0x00, 0xc0, 0x4f, 0x7b, 0xdf, 0x10 };
  int get_MaxBarsBack(out int pVal);
  int get_CurrentBar(EN_DATA_STREAM enDataStream, out int pVal);
  int get_Open(int nBarsBack, out double pVal);
  int get_Close(int nBarsBack, out double pVal);
  int get_Low(int nBarsBack, out double pVal);
  int get_High(int nBarsBack, out double pVal);
  int get_Variables(VARIANT v, out IEasyLanguageVariable pVal);
  int get_DataStream(out EN_DATA_STREAM pVal);
  int get_Volume(int nBarsBack, out int pVal);
  int get_OpenInt(int nBarsBack, out int pVal);
  int get_OpenMD(EN_DATA_STREAM enDataStream, out IEasyLanguagePrice pVal);
  int get_CloseMD(EN_DATA_STREAM enDataStream, out IEasyLanguagePrice pVal);
  int get_HighMD(EN_DATA_STREAM enDataStream, out IEasyLanguagePrice pVal);
  int get_LowMD(EN_DATA_STREAM enDataStream, out IEasyLanguagePrice pVal);
  int get_VolumeMD(EN_DATA_STREAM enDataStream, out IEasyLanguagePrice pVal);
  int get_OpenIntMD(EN_DATA_STREAM enDataStream, out IEasyLanguagePrice pVal);
  int get_DateTimeMD(EN_DATA_STREAM enDataStream, out IEasyLanguageDateTime pVal);
  int get_UpTicksMD(EN_DATA_STREAM enDataStream, out IEasyLanguagePrice pVal);
  int get_DownTicksMD(EN_DATA_STREAM enDataStream, out IEasyLanguagePrice pVal);
  int get_DateTime(int nBarsBack, out double pVal);
  int get_VariablesCount(out int pVal);
  int get_Tag(out int pVal);
  int set_Tag(int pVal);
  int get_Properties(out IEasyLanguageProperties pVal);
  int get_Platform(out ITradeStationPlatform pVal);
  int get_Errors(out IEasyLanguageErrors pVal);
  int get_System(out IEasyLanguageSystem pVal);
  int get_ServerField(wchar* sName, EN_DATA_STREAM enDataStream, out IEasyLanguageServerField pVal);
}

interface IEasyLanguageVariable : IDispatch {
//  static GUID IID = { 0x7ceeb6fb, 0xd59e, 0x11d3, 0x83, 0x94, 0x00, 0xc0, 0x4f, 0x7b, 0xdf, 0x10 };
  int get_DataStream(out EN_DATA_STREAM pVal);
  int get_DataType(out enDataType pVal);
  int get_Size(out int pVal);
  int get_Name(out wchar* pVal);
  int get_IsSeries(out int pVal);
  int get_Value(int nBarsBack, out VARIANT pVal);
  int set_Value(int nBarsBack, VARIANT pVal);
  int get_Min(out double pVal);
  int get_Max(out double pVal);
  int get_AsInteger(int nBarsBack, out int pVal);
  int set_AsInteger(int nBarsBack, double pVal);
  int get_AsDouble(int nBarsBack, out double pVal);
  int set_AsDouble(int nBarsBack, double pVal);
  int get_AsString(int nBarsBack, out wchar* pVal);
  int set_AsString(int nBarsBack, wchar* pVal);
  int get_AsTrueFalse(int nBarsBack, out int pVal);
  int set_AsTrueFalse(int nBarsBack, int pVal);
  int get_AsDateTime(int nBarsBack, out double pVal);
  int set_AsDateTime(int nBarsBack, double pVal);
  int get_Dimensions(out int pVal);
  int get_SelectedIndex(int nIndex, out int pVal);
  int set_SelectedIndex(int nIndex, int pVal);
  int get_DimensionSize(int nIndex, out int pVal);
}

interface IEasyLanguagePrice : IDispatch {
//  static GUID IID = { 0x7ceeb6fd, 0xd59e, 0x11d3, 0x83, 0x94, 0x00, 0xc0, 0x4f, 0x7b, 0xdf, 0x10 };
  int get_DataStream(out EN_DATA_STREAM pVal);
  int get_DataType(out enDataType pVal);
  int get_Size(out int pVal);
  int get_Name(out wchar* pVal);
  int get_IsSeries(out int pVal);
  int get_Value(int nBarsBack, out VARIANT pVal);
  int get_Min(out double pVal);
  int get_Max(out double pVal);
  int get_AsInteger(int nBarsBack, out int pVal);
  int get_AsDouble(int nBarsBack, out double pVal);
  int get_AsString(int nBarsBack, out wchar* pVal);
  int get_AsTrueFalse(int nBarsBack, out int pVal);
  int get_AsDateTime(int nBarsBack, out double pVal);
  int get_BarsBack(out int pVal);
}

interface IEasyLanguageDateTime : IDispatch {
//  static GUID IID = { 0x7ceeb6f1, 0xd59e, 0x11d3, 0x83, 0x94, 0x00, 0xc0, 0x4f, 0x7b, 0xdf, 0x10 };
  int get_AsDate(int nBarsBack, out double pVal);
  int get_AsTime(int nBarsBack, out double pVal);
  int get_AsDateTime(int nBarsBack, out double pVal);
  int get_Year(int nBarsBack, out int pVal);
  int get_Month(int nBarsBack, out int pVal);
  int get_Day(int nBarsBack, out int pVal);
  int get_Hour(int nBarsBack, out int pVal);
  int get_Minutes(int nBarsBack, out int pVal);
  int get_Seconds(int nBarsBack, out int pVal);
  int get_Milliseconds(int nBarsBack, out int pVal);
  int get_AsString(int nBarsBack, out wchar* pVal);
}

interface IEasyLanguageProperties : IDispatch {
//  static GUID IID = { 0x85c382e0, 0x79f0, 0x4303, 0x95, 0xe0, 0xd0, 0x7a, 0x03, 0xd9, 0xe3, 0x04 };
  int get_Items(wchar* sPropertyName, out VARIANT pVal);
  int set_Items(wchar* sPropertyName, VARIANT pVal);
  int get_ItemsByInteger(int nPropertyId, out VARIANT pVal);
  int set_ItemsByInteger(int nPropertyId, VARIANT pVal);
}

interface ITradeStationPlatform : IDispatch {
//  static GUID IID = { 0xde1cb3ac, 0x908d, 0x4fa9, 0xa4, 0x18, 0xeb, 0x37, 0xc1, 0xe2, 0x59, 0xd8 };
  int get_PlatformType(out enPlatformType pVal);
  int get_CustomerID(out int pVal);
  int get_NetworkID(out int pVal);
}

interface IEasyLanguageErrors : IDispatch {
//  static GUID IID = { 0x9faf97f0, 0x876f, 0x447f, 0xbe, 0xf1, 0xda, 0xc9, 0xa6, 0x79, 0xbc, 0x44 };
  int RegisterError(TSRuntimeErrorItem* pErrorItem, out int pErrorID);
  int RaiseRuntimeError(int nErrorID);
  int RaiseRuntimeErrorEx(int nErrorID, VARIANT* pvParameters);
  int get_LastRuntimeError(out TSRuntimeErrorItem pVal);
}

interface IEasyLanguageSystem : IDispatch {
//  static GUID IID = { 0x607bbd7e, 0x24bd, 0x49fb, 0x99, 0x8d, 0x7c, 0x10, 0xe3, 0x2e, 0x0f, 0x33 };
  int get_Array(out IELFrameworkArray pVal);
}

interface IELFrameworkArray : IDispatch {
//  static GUID IID = { 0xe0c22711, 0x9e2a, 0x4778, 0x9e, 0x79, 0x5a, 0xca, 0xcd, 0x1e, 0xfc, 0x46 };
  int New(int nSize, VARIANT vDefaultValue, out int pnHandle);
  int SetValue(int nHandle, int nIndex, VARIANT vValue);
  int GetValue(int nHandle, int nIndex, out VARIANT pvValue);
  int SetValueRange(int nHandle, int nBegin, int nEnd, VARIANT vValue);
  int Copy(int nSourceHandle, int nDestHandle, int nSourceIndex, int nDestIndex, int nCount);
  int Compare(int nSourceHandle, int nDestHandle, int nSourceIndex, int nDestIndex, int nCount, out int pnResult);
  int IsValidHandle(int nHandle, out int pVal);
  int Sort(int nHandle, int nBegin, int nEnd, int bAscending);
  int Sum(int nHandle, int nBegin, int nEnd, out double pVal);
  int get_DataType(int nHandle, out enDataType pVal);
  int get_Count(int nHandle, out int pVal);
  int Resize(int nHandle, int nNewSize);
  int SetIntegerValue(int nHandle, int nIndex, int nNewValue);
  int SetFloatValue(int nHandle, int nIndex, double dNewValue);
  int GetIntegerValue(int nHandle, int nIndex, out int pnValue);
  int GetFloatValue(int nHandle, int nIndex, out double pdValue);
}

interface IEasyLanguageServerField : IDispatch {
//  static GUID IID = { 0xf0e68158, 0xca95, 0x45d0, 0x98, 0x2d, 0x9d, 0xc6, 0x6d, 0x44, 0xdb, 0x06 };
  int get_DataStream(out EN_DATA_STREAM pVal);
  int get_DataType(out enDataType pVal);
  int get_Size(out int pVal);
  int get_Name(out wchar* pVal);
  int get_IsSeries(out int pVal);
  int get_Value(int nBarsBack, out VARIANT pVal);
  int get_Min(out double pVal);
  int get_Max(out double pVal);
  int get_AsInteger(int nBarsBack, out int pVal);
  int get_AsDouble(int nBarsBack, out double pVal);
  int get_AsString(int nBarsBack, out wchar* pVal);
  int get_AsTrueFalse(int nBarsBack, out int pVal);
  int get_AsDateTime(int nBarsBack, out double pVal);
  int get_BarsBack(out int pVal);
}

interface IEasyLanguageDataElement : IDispatch {
//  static GUID IID = { 0x7ceeb6f8, 0xd59e, 0x11d3, 0x83, 0x94, 0x00, 0xc0, 0x4f, 0x7b, 0xdf, 0x10 };
  int get_DataStream(out EN_DATA_STREAM pVal);
  int get_DataType(out enDataType pVal);
  int get_Size(out int pVal);
  int get_Name(out wchar* pVal);
  int get_IsSeries(out int pVal);
}

interface IEasyLanguageVector : IDispatch {
//  static GUID IID = { 0x7ceeb6fa, 0xd59e, 0x11d3, 0x83, 0x94, 0x00, 0xc0, 0x4f, 0x7b, 0xdf, 0x10 };
  int get_Value(int nBarsBack, out VARIANT pVal);
  int set_Value(int nBarsBack, VARIANT pVal);
  int get_Min(out double pVal);
  int get_Max(out double pVal);
  int get_AsInteger(int nBarsBack, out int pVal);
  int set_AsInteger(int nBarsBack, double pVal);
  int get_AsDouble(int nBarsBack, out double pVal);
  int set_AsDouble(int nBarsBack, double pVal);
  int get_AsString(int nBarsBack, out wchar* pVal);
  int set_AsString(int nBarsBack, wchar* pVal);
  int get_AsTrueFalse(int nBarsBack, out int pVal);
  int set_AsTrueFalse(int nBarsBack, int pVal);
  int get_AsDateTime(int nBarsBack, out double pVal);
  int set_AsDateTime(int nBarsBack, double pVal);
}

interface IEasyLanguageReadOnlyVector : IDispatch {
//  static GUID IID = { 0x7ceeb6f9, 0xd59e, 0x11d3, 0x83, 0x94, 0x00, 0xc0, 0x4f, 0x7b, 0xdf, 0x10 };
  int get_Value(int nBarsBack, out VARIANT pVal);
  int get_Min(out double pVal);
  int get_Max(out double pVal);
  int get_AsInteger(int nBarsBack, out int pVal);
  int get_AsDouble(int nBarsBack, out double pVal);
  int get_AsString(int nBarsBack, out wchar* pVal);
  int get_AsTrueFalse(int nBarsBack, out int pVal);
  int get_AsDateTime(int nBarsBack, out double pVal);
  int get_BarsBack(out int pVal);
}

interface IEasyLanguageEvent : IDispatch {
//  static GUID IID = { 0x7ceeb6ff, 0xd59e, 0x11d3, 0x83, 0x94, 0x00, 0xc0, 0x4f, 0x7b, 0xdf, 0x10 };
  int AddDLLFunction(wchar* bstrDLLName, wchar* bstrFunctionName);
  int get_Count(out int pVal);
  int InvokeEvent(int nIndex, VARIANT* pvParams, out VARIANT pvRet);
  int AddMethod(int nObjectThis, int nMethodAddress);
  int Execute(VARIANT* pvParams, VARIANT* pvRetVal);
}

/*
abstract class ELExecutionContext {
  static GUID CLSID = { 0x7ceeb6f3, 0xd59e, 0x11d3, 0x83, 0x94, 0x00, 0xc0, 0x4f, 0x7b, 0xdf, 0x10 };
  mixin CoInterfaces!(IEasyLanguageObject);
}

abstract class ELVariable {
  static GUID CLSID = { 0x7ceeb6f4, 0xd59e, 0x11d3, 0x83, 0x94, 0x00, 0xc0, 0x4f, 0x7b, 0xdf, 0x10 };
  mixin CoInterfaces!(IEasyLanguageVariable, IEasyLanguageDataElement, IEasyLanguageVector);
}

abstract class ELServerField {
  static GUID CLSID = { 0x63c12369, 0xc51e, 0x48de, 0xbe, 0x5c, 0xce, 0x14, 0xa5, 0x8e, 0x30, 0xa8 };
  mixin CoInterfaces!(IEasyLanguageServerField, IEasyLanguageDataElement, IEasyLanguageVector);
}

abstract class ELPrices {
  static GUID CLSID = { 0x7ceeb6f5, 0xd59e, 0x11d3, 0x83, 0x94, 0x00, 0xc0, 0x4f, 0x7b, 0xdf, 0x10 };
  mixin CoInterfaces!(IEasyLanguagePrice, IEasyLanguageDataElement, IEasyLanguageReadOnlyVector);
}

abstract class ELVolume {
  static GUID CLSID = { 0x7ceeb6f6, 0xd59e, 0x11d3, 0x83, 0x94, 0x00, 0xc0, 0x4f, 0x7b, 0xdf, 0x10 };
  mixin CoInterfaces!(IEasyLanguagePrice, IEasyLanguageDataElement, IEasyLanguageReadOnlyVector);
}

abstract class ELBarDateTime {
  static GUID CLSID = { 0x7ceeb6f2, 0xd59e, 0x11d3, 0x83, 0x94, 0x00, 0xc0, 0x4f, 0x7b, 0xdf, 0x10 };
  mixin CoInterfaces!(IEasyLanguageDateTime);
}

abstract class EasyLanguageEvent {
  static GUID CLSID = { 0x7ceeb6f7, 0xd59e, 0x11d3, 0x83, 0x94, 0x00, 0xc0, 0x4f, 0x7b, 0xdf, 0x10 };
  mixin CoInterfaces!(IEasyLanguageEvent);
}

abstract class TradeStationPlatform {
  static GUID CLSID = { 0x404cdc4f, 0x6e29, 0x4bc4, 0x9a, 0x20, 0x4a, 0x23, 0xd8, 0x7f, 0xbb, 0x21 };
  mixin CoInterfaces!(ITradeStationPlatform);
}

abstract class EasyLanguageProperties {
  static GUID CLSID = { 0xceb1e2bc, 0xccb8, 0x4679, 0x82, 0x85, 0x63, 0xa9, 0x48, 0xda, 0x99, 0xd0 };
  mixin CoInterfaces!(IEasyLanguageProperties);
}

abstract class EasyLanguageErrors {
  static GUID CLSID = { 0x47897b32, 0xc871, 0x49e4, 0x96, 0x95, 0x17, 0x9b, 0xcc, 0x10, 0x4d, 0x62 };
  mixin CoInterfaces!(IEasyLanguageErrors);
}

abstract class EasyLanguageSystem {
  static GUID CLSID = { 0xa1ce4bf8, 0xf337, 0x469d, 0x86, 0x11, 0x83, 0x28, 0xa7, 0xbf, 0xb4, 0x85 };
  mixin CoInterfaces!(IEasyLanguageSystem);
}

abstract class ELFrameworkArray {
  static GUID CLSID = { 0xa7ff86f1, 0xcda1, 0x4171, 0xb0, 0x72, 0xf0, 0x44, 0x41, 0xea, 0xf8, 0x1c };
  mixin CoInterfaces!(IELFrameworkArray);
}
*/